#pragma once

#include "Common.h"
//#include "PageMap.h"
#include "unordered_map"

class PagesCache : public nocopy
{
	static PagesCache pages_cache;
public:
	static PagesCache* GetCentralCache() { return &pages_cache; }

	Span* Alloc(unsigned pages);
	void Dealloc(Span* span);

	std::mutex& mtx() { return _mtx; }
	ObjectPool<Span>& SpanPool() { return _span_pool; };
	std::unordered_map<PAGE_ID, Span*>& Hash() { return _hash; }

private:
	SpanList _pages[MAX_PAGES_COUNT];
	std::mutex _mtx; 
	std::unordered_map<PAGE_ID, Span*> _hash;
	ObjectPool<Span> _span_pool;
};

